package com.software.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @BelongsProject: Second-hand-trading-platform
 * @BelongsPackage: com.software.config
 * @Author: wyj
 * @CreateTime: 2024-03-03  01:33
 * @Description:
 * @Version: 1.0
 */
@Configuration
public class WebMvcConfiguration extends WebMvcConfigurationSupport {
    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {

        registry.addResourceHandler("/static/**").addResourceLocations(
                "classpath:/static/"
        );
        // 静态资源配置 对于所有访问路径以/file/开始的请求，应该将它们映射到文件系统上的E:/img/目录。
        registry.addResourceHandler("/file/**").addResourceLocations("file:E:/img/");
        //http://localhost:8082/file/003737110ce94a8cbfcb0fc6ec0542a6.jpg

        super.addResourceHandlers(registry);
    }

}
